package com.mylibraryapplication.activity;

import android.support.annotation.ColorInt;

import com.larswerkman.lobsterpicker.OnColorListener;
import com.larswerkman.lobsterpicker.sliders.LobsterShadeSlider;
import com.mylibrary.view.progress.CircularFillableLoaders;
import com.mylibraryapplication.R;
import com.mylibraryapplication.base.BaseActivity;

import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar;

/**
 * @author yinsujun  Created at 2016/8/2 14:28
 */
public class ProgressBarActivity extends BaseActivity {
    private CircularFillableLoaders circularFillableLoaders;

    @Override
    public int getLayoutId() {
        return R.layout.activity_progress_bar;
    }

    @Override
    public void initView() {
        circularFillableLoaders = (CircularFillableLoaders) findViewById(R.id.circularFillableLoaders);
        // PROGRESS
        ((DiscreteSeekBar) findViewById(R.id.seekBarProgress)).setOnProgressChangeListener(new DiscreteSeekBar.OnProgressChangeListener() {
            @Override
            public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
                circularFillableLoaders.setProgress(value);
            }

            @Override
            public void onStartTrackingTouch(DiscreteSeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(DiscreteSeekBar seekBar) {

            }
        });

        // BORDER
        ((DiscreteSeekBar) findViewById(R.id.seekBarBorderWidth)).setOnProgressChangeListener(new DiscreteSeekBar.OnProgressChangeListener() {
            @Override
            public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
                circularFillableLoaders.setBorderWidth(value * getResources().getDisplayMetrics().density);
            }

            @Override
            public void onStartTrackingTouch(DiscreteSeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(DiscreteSeekBar seekBar) {
            }
        });

        // AMPLITUDE
        ((DiscreteSeekBar) findViewById(R.id.seekBarAmplitude)).setOnProgressChangeListener(new DiscreteSeekBar.OnProgressChangeListener() {
            @Override
            public void onProgressChanged(DiscreteSeekBar seekBar, int value, boolean fromUser) {
                circularFillableLoaders.setAmplitudeRatio((float) value / 1000);
            }

            @Override
            public void onStartTrackingTouch(DiscreteSeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(DiscreteSeekBar seekBar) {
            }
        });

        // COLOR
        ((LobsterShadeSlider) findViewById(R.id.shadeslider)).addOnColorListener(new OnColorListener() {
            @Override
            public void onColorChanged(@ColorInt int color) {
                circularFillableLoaders.setColor(color);
            }

            @Override
            public void onColorSelected(@ColorInt int color) {
            }
        });
    }
}
